package com.java.jvm.bytecode;
import com.java.jvm.bytecode.service.CycleService;
import java.lang.management.ManagementFactory;
import java.util.concurrent.TimeUnit;

public class CycleServiceTests {
    public static void main(String[] args) throws InterruptedException {
        //1.获取这个方法对应的jvm进程id
        String name = ManagementFactory.getRuntimeMXBean().getName();
        System.out.println("name="+name);
        String pid=name.split("@")[0];
        System.out.println("pid="+pid);
        CycleService cycleService=new CycleService();
        while(true){
            cycleService.doCycle();
            TimeUnit.SECONDS.sleep(3);
        }
    }
}
